﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using SPWarmup;

namespace SPWarmUp.Library.Web
{
    public class SPWarmUpConfigController : ISpWarmUpConfigController
    {
        public SPWarmUpConfigController()
        {
                
        }

        public IEnumerable<string> GetWebApplicationUrls()
        {
            var topo = Library.WarmUpServiceLocator.GetType<ITopologyService>();
            var apps = topo.GetContentApplications();

            return apps.Select(app => app.AlternateUrls[0].Uri.AbsoluteUri);

        }

        public void CreateTimerJob(IEnumerable<string> urls, SPSchedule schedule)
        {
            var bootstrapper = new FeatureBootStrapper();
            bootstrapper.InstallTimerJob(schedule);
        }
    }
}
